using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace Test {
	class BulkCopy {


		static void MainZ() {

			SqlConnectionStringBuilder cb=new SqlConnectionStringBuilder();
			cb.DataSource="(local)\\sql2012";
			cb.InitialCatalog="DirectoryTest";
			cb.IntegratedSecurity=true;
			SqlConnection cnn=new SqlConnection(cb.ConnectionString);

			// Getting source data
			SqlCommand cmd=new SqlCommand("SELECT * FROM BulkPutaway",cnn);
			cnn.Open();
			SqlDataReader rdr=cmd.ExecuteReader();

			// Initializing an SqlBulkCopy object
			SqlBulkCopy sbc=new SqlBulkCopy("server=(local)\\sql2012;database=DirectoryTest;Integrated Security=SSPI");

			// Copying data to destination
			sbc.DestinationTableName="Temp";
			sbc.WriteToServer(rdr);

			// Closing connection and the others
			sbc.Close();
			rdr.Close();
			cnn.Close();

			//using(SqlBulkCopy s=new SqlBulkCopy(destConnection))
			//{
			//  s.DestinationTableName="SalesCopy2";
			//  s.NotifyAfter=10000;
			//  s.SqlRowsCopied+=new SqlRowsCopiedEventHandler(s_SqlRowsCopied);

			//  s.WriteToServer(sourceTable);
			//  s.Close();
			//}



		}


	}
}
